Namespace persistent
    Public Class BayiKoduGuncelleme
        Public Shared Function DealerUpdate(ByVal msisdn As String, ByVal dealerCode As String, ByRef resultMessage As String) As Boolean
            Dim result1 As Boolean = False

            Try

                persistent.myDBConn.ORAProcedure("eu_bill.case_bscs.case_dealer_update", New String() {"VAR_msisdn", "VAR_deal_code"}, New String() {msisdn, dealerCode})

                Return True

            Catch ex As Exception
                resultMessage = ex.Message
            End Try
            Return result1

        End Function
        Public Shared Function getDealerCode(ByVal msisdn As String, ByRef resultMessage As String) As String
            Dim dealerCode As String
            Try
                dealerCode = persistent.myDBConn.ORAFunction("eu_bill.get_dealer_code", New String() {"p_msisdn"}, New String() {msisdn})
                Return dealerCode
            Catch ex As Exception
                resultMessage = ex.Message
            End Try
        End Function
        Public Shared Function getDealerUpdateLog(ByVal msisdn As String, ByVal userCode As String, ByVal startDate As String, ByVal endDate As String) As DataTable
            Dim query As String = "select a.msisdn, " & _
                             vbNewLine & "a.old_dealer_code, " & _
                             vbNewLine & "a.new_dealer_code, " & _
                             vbNewLine & "a.request_date, " & _
                             vbNewLine & "a.user_id " & _
                             vbNewLine & "  from eu_bill.dealer_code_update_log a " & _
                             vbNewLine & " where msisdn= nvl('" & msisdn & "',msisdn) " & _
                             vbNewLine & "   and user_id = nvl('" & userCode & "',user_id) "
            If startDate.Trim.Length > 0 Then
                query &= " and a.request_date >= to_date('" & startDate.Trim() & "', 'dd.MM.yyyy')"
            End If

            If endDate.Trim.Length > 0 Then
                query &= " and a.request_date < to_date('" & endDate.Trim() & " 23:59:59', 'dd.MM.yyyy HH24:mi:ss')"
            End If
            Dim gen As Object = New BayiKoduGuncellemeReport()
            Return persistent.myDBConn.myORATable_LOG(query, "null", "null", "null", msisdn, "Select(getDealerUpdateLog)", "BayiKoduGuncelleme", gen.session("user"))
        End Function
        Public Shared Function getDealerUpdateLog() As DataTable
            Dim query As String = "select a.msisdn, " & _
                             vbNewLine & "a.old_dealer_code, " & _
                             vbNewLine & "a.new_dealer_code, " & _
                             vbNewLine & "a.request_date, " & _
                             vbNewLine & "a.user_id " & _
                             vbNewLine & "  from eu_bill.dealer_code_update_log a "
            Return persistent.myDBConn.myORATable(query)
        End Function
    End Class
End Namespace

